﻿module Sustainalytics.Research {

    // controller used for ResearchMenu
    export class ResearchMenuController {

        public companyNameQueryString: string;
        public gcPermissions: GCCS.Security.GCPermissions;
        public hasCompanyPI: boolean;
        public hasCompanyOverview: boolean;

        constructor(
            private $scope: ng.IScope,
            private $q: ng.IQService,
            private $routeParams: ng.route.IRouteParamsService,
            private $location: ng.ILocationService,
            private GCPermissionsService: Sustainalytics.GCCS.Security.GCPermissionsService,
            private PIPermissionsService: Sustainalytics.ProductInvolvement.Security.PIPermissionsService,
            private PortfolioService: Sustainalytics.Portfolio.PortfolioService
            ) {

            var ctx = this;

            $scope['researchMenu'] = ctx;

            // get company name from route params
            var companyName: string = ctx.$routeParams['companyName'];
            ctx.companyNameQueryString = companyName;

            // get GCCS permissions
            ctx.gcPermissions = ctx.GCPermissionsService.getPermissions();
            ctx.hasCompanyPI = ctx.PIPermissionsService.hasCompanyPI();
            ctx.hasCompanyOverview = ctx.PortfolioService.hasPermision();
        }

        // get current location path
        public getCurrentPath(): string {
            var ctx = this;
            return ctx.$location.path();
        }
    }


    angular.module('Sustainalytics.Research').controller('ResearchMenuController', ResearchMenuController);
} 